<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>

<TITLE>CheckBoxList实例</TITLE> 

<style type="text/css">
<script language="JavaScript"> 
 	function SetCheckBoxState(str) 
	{ 
		o = document.getElementsByTagName("INPUT") 

		var val=0; 
		for(i=0;i<o.length;i++) 
		{ 
		if(o[i].type=="checkbox" && o[i].checked && o[i].name==str) 
		{ 
		val = val + 1; 
			} 
		if(val > 2) 
				{	 
			alert('你选择的项目只能在2个以内！') 
			o[i].checked=false; 
		return; 
			} 

		} 
	</script>

</style>
</head>

<body>
	<input type="checkbox" name="INPUT" onclick="SetCheckBoxState(this.value)"/> 唱歌<br/>
	<input type="checkbox" name="INPUT" onclick="SetCheckBoxState(this.value)"/> 唱歌1<br/>
	<input type="checkbox" name="INPUT" onclick="SetCheckBoxState(this.value)"/> 唱歌2<Br/>

</body>

</html>
